import thirdAppConfig from '../../../api/config/thirdPartyApp'
import * as globalTypes from '../../../mutation-types'
export const getThirdthAppList = ({commit}, data) => {
  return thirdAppConfig.getThirdthAppList(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 获取第三方接口列表
 * @param data
 */
export const getListByAppType = ({commit}, data) => {
  return thirdAppConfig.getListByAppType(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}

/**
 * 添加第三方接口
 * @param data
 */
export const addThirdAppConfig = ({commit}, data) => {
  return thirdAppConfig.addThirdAppConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 编辑第三方接口
 * @param data
 */
export const updateThirdAppConfig = ({commit}, data) => {
  return thirdAppConfig.updateThirdAppConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 删除第三方接口
 * @param data
 */
export const deleteThirdAppConfig = ({commit}, data) => {
  return thirdAppConfig.deleteThirdAppConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 获取第三方应用列表
 * @param data
 */
export const getApplications = ({commit}, data) => {
  return thirdAppConfig.getApplications(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
